package org.jeecg.modules.music.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.music.entity.dto.HomeMusCountDto;
import org.jeecg.modules.music.service.IMusAlbumSongListService;
import org.jeecg.modules.music.service.IMusArtistService;
import org.jeecg.modules.music.service.IMusSongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Api(tags="音乐系统")
@RestController
@RequestMapping("/mus/index")
public class MusicIndexController {

    @Autowired
    private IMusSongService songService;

    @Autowired
    private IMusArtistService artistService;

    @Autowired
    private IMusAlbumSongListService albumSongListService;


    @ApiOperation("首页-歌曲统计")
    @RequestMapping(value = "/song/chart",method = RequestMethod.GET)
    public Result<List<HomeMusCountDto>> getSongCategoryCount(@RequestParam(name = "type",required = true) Integer type){
        //语种
        if (type==1){
            return Result.ok(songService.queryGroupLanguage());
        }else if (type==2){
            return Result.ok(songService.queryGroupGenre());
        }else {
            return Result.error("查询失败");
        }
    }

    @ApiOperation("首页-歌手统计")
    @RequestMapping(value = "/singers/chart",method = RequestMethod.GET)
    public Result<List<HomeMusCountDto>> getSingersCategoryCount(@RequestParam(name = "type",required = true) Integer type){
        //语种
        if (type==1){
            return Result.ok(artistService.queryGroupCountry());
        }else if (type==2){
            return Result.ok(artistService.queryGroupSex());
        }else if (type==3){
            return Result.ok(artistService.queryGroupIsEnter());
        }
        else {
            return Result.error("查询失败");
        }
    }

    @ApiOperation("首页-歌单统计")
    @RequestMapping(value = "/songlist/chart",method = RequestMethod.GET)
    public Result<List<HomeMusCountDto>> getSonglistCategoryCount(@RequestParam(name = "type",required = true) Integer type){
        //语种
        if (type==1){
            return Result.ok(albumSongListService.queryGroupRecommend());
        }else if (type==2){
            return Result.ok(albumSongListService.queryGroupArea());
        }
        else {
            return Result.error("查询失败");
        }
    }

    @ApiOperation("首页-歌单统计")
    @RequestMapping(value = "/albums/chart",method = RequestMethod.GET)
    public Result<List<HomeMusCountDto>> getAlbumsCategoryCount(@RequestParam(name = "type",required = true) Integer type){
        //语种
        if (type==1){
            return Result.ok(albumSongListService.queryGroupRecommendAlbums());
        }else if (type==2){
            return Result.ok(albumSongListService.queryGroupAreaAlbums());
        }
        else {
            return Result.error("查询失败");
        }
    }
}
